
#ifndef INCLUDED_WIN32WINDOW_H
#define INCLUDED_WIN32WINDOW_H

#ifdef WIN32

#include "win32.h"

namespace tinkle {

// I create this class to get a window handle. To get a asynchronous socket' s
// readable or writable notification, I choose the WSASyncSelect function, for
// I can' t find another function having the notify ability, : ( .
// And WSASyncSelect requires an HWND argument. Maybe there is a better
// solution, Currently I choose this ugly implement.
class Win32Window {
public:
    Win32Window();
    virtual ~Win32Window();
    // create a window
    bool Create(HWND parent, LPCTSTR title, DWORD style = 0,
        DWORD exStyle = 0, int x = 0, int y = 0, int cx = 10, int cy = 10);
    // get a window handle
    HWND Handle() const;

protected:
    virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam,
        LRESULT &result);
private:
    static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam,
                                                            LPARAM lParam);
    HWND _handle;
    static HINSTANCE _instance;
    static ATOM _wndClass;
};

}

#endif

#endif